<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="layout" content="bocMain"/>
    <title>进件作业系统</title>
</head>

<body>
<header class="header-title">职业信息</header>

<g:form action="contactProfessionalInfoSave" method="post" class="myForm weui-label-9">
    <input type="hidden" name="id" id="id" value="${this?.opportunity?.id}">

    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">现工作单位</label></div>

            <div class="weui-cell__bd">
                <g:textField class="weui-input" id="companyName" name="contact.companyName"
                             value="${this?.opportunity?.contact?.companyName}" placeholder="请输入"></g:textField>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">工作单位地址4*</label></div>
            <div class="weui-cell__bd">
                <g:textField class="weui-input" name="name4" id="name4" value="CN：中国" readonly="true"/>
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">工作单位地址3*</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.companyProvince" id="companyProvince" from="${com.next.Province.list()}" optionValue="name" optionKey="id" value="${this.opportunity?.contact?.companyProvince?.id}" noSelection="${['': '请选择']}"/>
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">工作单位地址2*</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.companyCity" id="companyCity" from="${com.next.City.findAllByProvince(this?.opportunity?.contact?.companyProvince)}" optionValue="name" optionKey="id" value="${this.opportunity?.contact?.companyCity?.id}" noSelection="${['': '请选择']}"/>
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">工作单位地址1*</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.companyDistrict" id="companyDistrict" from="${com.next.District.findAllByCity(this?.opportunity?.contact?.companyCity)}" optionKey="id" optionValue="name" value="${this.opportunity?.contact?.companyDistrict?.id}" noSelection="${['': '请选择']}"/>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">工作单位地址详情</label></div>

            <div class="weui-cell__bd">
                <textArea class="weui-textarea autoheighTextArea" name="contact.companyAddress" id="companyAddress" placeholder="请输入">${this?.opportunity?.contact?.companyAddress}</textArea>

            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">工作单位邮编</label></div>

            <div class="weui-cell__bd">
                <g:textField class="weui-input" id="companyZipCode" name="contact.companyZipCode"
                             value="${this?.opportunity?.contact?.companyZipCode}" placeholder="请输入"></g:textField>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">工作单位电话</label></div>

            <div class="weui-cell__bd">
                <g:textField class="weui-input" id="companyPhone" name="contact.companyPhone"
                             value="${this?.opportunity?.contact?.companyPhone}" placeholder="请输入"></g:textField>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">本单位行业</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" id="industry" name="contact.industry" from="${com.next.Industry.list()}" optionKey="id" optionValue="name" value="${this?.opportunity?.contact?.industry?.id}" noSelection="${['': '请选择']}"></g:select>

            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">经济类型</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" id="companyEconomyType" name="contact.companyEconomyType" from="${com.next.AccountEconomyType.list()}" optionKey="id" optionValue="name" value="${this?.opportunity?.contact?.companyEconomyType?.id}" noSelection="${['': '请选择']}"></g:select>

            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">职业</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.profession" id="profession" value="${this.opportunity?.contact?.profession?.id}" optionKey="id"
                          optionValue="name" from="${com.next.ContactProfession.list()}" noSelection="${['': '请选择']}"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">职称</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.professionTile" id="contact.professionTile" value="${this.opportunity?.contact?.professionTile?.id}" optionKey="id"
                          optionValue="name" from="${com.next.ContactProfessionTitle.list()}" noSelection="${['': '请选择']}"/>
            </div>
        </div>

         <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">职务</label></div>
            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.contactJob" id="contact.contactJob" value="${this.opportunity?.contact?.contactJob?.id}" optionKey="id"
                          optionValue="name" from="${com.next.ContactJob.list()}" noSelection="${['': '请选择']}"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">参加工作日期</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" id="workTime" name="workTime" placeholder="请输入" value="2019-01-01 &nbsp;">
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">现工作日期</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" id="currentWorkTime" name="currentWorkTime" placeholder="请输入" value="2019-01-01 &nbsp;">
            </div>
        </div>

        <!-- <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">现单位工作年限</label></div>
            <div class="weui-cell__bd">
                <g:textField class="weui-input" id="currentSeniority" name="contact.currentSeniority" value="${this?.opportunity?.contact?.currentSeniority}" placeholder="请输入" readonly="true"></g:textField>
            </div>
            <div class="weui-cell__hd"><label class="weui-label rightUnit">年</label></div>
        </div> -->
    </div>
</g:form>
<div class="bigBtn">
    <button type="button" class="weui-btn weui-btn_primary" id="submit">下一步</button>
</div>
<asset:javascript src="boc/textAutoHeight.js"/>

<script>

    $(function ()
    {
        // 使用
        $('textarea').autoHeight();
        // $("#workTime").change(function() {
        //     var workTime = $("#workTime").val();
        //     var currentWorkTime = $("#currentWorkTime").val();
        //     $("#currentSeniority").val(getCurrentSeniority(workTime, currentWorkTime));
        // })

        // $("#currentWorkTime").change(function() {
        //     var workTime = $("#workTime").val();
        //     var currentWorkTime = $("#currentWorkTime").val();
        //     $("#currentSeniority").val(getCurrentSeniority(workTime, currentWorkTime));
        // })

        $("#workTime").datetimePicker({
            title: "选择参加工作日期",
            toolbarCloseText: "完成",
            times: function() {
                return [{
                    values: ['&nbsp;']
                }]
            },
        });
        $("#currentWorkTime").datetimePicker({
            title: "选择现工作时间",
            toolbarCloseText: "完成",
            times: function() {
                return [{
                    values: ['&nbsp;']
                }]
            },
        });
        $("#submit").click(function () {

            var companyName = $("#companyName").val().trim();
            if (!companyName) {
                helpMessage("请输入现工作单位");
                return;
            }

            var companyAddress = $("#companyAddress").val().trim();
            if (!companyAddress) {
                helpMessage("请输入现工作地址");
                return;
            }

            var companyZipCode = $("#companyZipCode").val().trim();
            if (companyZipCode && companyZipCode.length > 6) {
                helpMessage("请输入正确邮编");
                return;
            }

            $(".myForm").submit();
        })

        function helpMessage(message) {
            $(".helpMsg").text(message).fadeIn(200);
            setTimeout(function () {
                $(".helpMsg").fadeOut(200);
            }, 2000);
        }

        function getCurrentSeniority(workTime, currentWorkTime)
        {
            if (workTime && currentWorkTime)
            {
                return Number(currentWorkTime.substring(0,4)) - Number(workTime.substring(0,4));
            }
            else
            {
                return 0;
            }
        }

        $("#companyProvince").bind("change", function(){
            $("#companyCity option").remove();
            $("#s2id_companyCity span:first").html("请选择");
            $("#companyCity").append("<option value='' >请选择</option>")
            $("#companyDistrict option").remove();
            $("#s2id_companyDistrict span:first").html("请选择");
            $("#companyDistrict").append("<option value='' >请选择</option>")
            var companyProvince = $("#companyProvince").val()
            if(!companyProvince){
                return
            }
            $.ajax({
                url: "/bocAppOpportunity/getCityByProvinceId",
                type: "POST",
                data: {'provinceId': companyProvince} ,
                success: function(result){
                    for(var i=0; i < result.list.length; i++){
                        $("#companyCity").append("<option value=" + result.list[i].id + ">" + result.list[i].name + "</option>")
                    }
                }
            });
        });

        $("#companyCity").bind("change", function(){
            $("#companyDistrict option").remove();
            $("#s2id_companyDistrict span:first").html("请选择");
            $("#companyDistrict").append("<option value='' >请选择</option>")
            var companyCity = $("#companyCity").val()
            if(!companyCity){
                return
            }
            $.ajax({
                url: "/bocAppOpportunity/getDistrictByCityId",
                type: "POST",
                data: {'cityId': companyCity} ,
                success: function(result){
                    for(var i=0; i < result.list.length; i++){
                        $("#companyDistrict").append("<option value=" + result.list[i].id + ">" + result.list[i].name + "</option>")
                    }
                }
            });
        });
    })


</script>
</body>
</html>
